//引入项目中全部的全局组件
import SvgIcon from "./SvgIcon/index.vue";
import Pagination from "./Pagination/index.vue";
import Category from "./Category/index.vue";
import { App, Component } from "vue";
//引入element-ui图标进行全局注册
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
//全局对象
const allGlobalComponents: Record<string, Component> = {
  SvgIcon,
  Pagination,
  Category,
};
export default {
  // 通过 install 方法安装到 Vue 应用实例上
  install(app: App) {
    //注册项目中全部的全局组件
    Object.keys(allGlobalComponents).forEach((key) => {
      //注册为全局组件
      app.component(key, allGlobalComponents[key]);
    });

    //注册全局图标
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      if (key === "Menu") {
        app.component("MenuIcon", component);
      } else {
        app.component(key, component);
      }
    }
  },
};
